package com.ysdwl.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysdwl.model.Bill;
import com.ysdwl.service.impl.BillService;
import com.ysdwl.service.impl.ProviderService;

@WebServlet(urlPatterns = "/billAdd")
public class BillAddServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		try {
			
		
		String billId = req.getParameter("billId");
		String billName = req.getParameter("billName");
		String billCom = req.getParameter("billCom");
		String productDesc = req.getParameter("productDesc");
		double billNum = Double.parseDouble(req.getParameter("billNum"));
		double money = Double.parseDouble(req.getParameter("money"));
		int supplier = Integer.parseInt(req.getParameter("supplier"));
		int zhifu = Integer.parseInt(req.getParameter("zhifu"));
		Date date = new Date();
		
		Bill bill = new Bill(billId,billName,productDesc,billCom,billNum,money,zhifu,date,supplier);
		BillService billService = new BillService();

		billService.insertModel(bill);
		
		resp.sendRedirect("billList");
		
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
